package o;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.view.View;
import androidx.annotation.NonNull;
import com.huawei.skinner.attrentry.SkinAttrFactory;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import o.fku.a;

public class fpf {
    private static final Map<String, fku> ˊ = new HashMap();
    private static final Map<String, fku> ˋ = new HashMap();
    private static final Map<String, Map<String, Field>> ˎ = new HashMap();
    private View ˏ;
    private fku ॱ;
    private String ॱॱ;

    static {
        fku ˊ = new a().ˏ("style").ˎ("android.widget.Switch").ˊ("com.android.internal.R$styleable").ˋ("Switch").ˎ(new String[]{"Switch_thumb", "Switch_track"}).ॱ(new String[]{"thumb", "track"}).ˊ();
        ˋ.put(ˊ.ˎ(), ˊ);
        ˊ = new a().ˏ("style").ˎ("com.huawei.support.widget.HwSwitch").ˊ("com.android.internal.R$styleable").ˋ("Switch").ˎ(new String[]{"Switch_thumb", "Switch_track"}).ॱ(new String[]{"thumb", "track"}).ˊ();
        ˋ.put(ˊ.ˎ(), ˊ);
        ˊ = new a().ˏ("style").ˎ("androidx.appcompat.widget.SwitchCompat").ˊ("androidx.appcompat.R$styleable").ˋ("Switch").ˎ(new String[]{"Switch_thumb", "Switch_track"}).ॱ(new String[]{"thumb", "track"}).ˊ();
        ˋ.put(ˊ.ˎ(), ˊ);
        ˊ = new a().ˏ("style").ˎ("android.widget.ProgressBar").ˊ("com.android.internal.R$styleable").ˋ("ProgressBar").ˎ(new String[]{"ProgressBar_progressDrawable", "ProgressBar_indeterminateDrawable"}).ॱ(new String[]{"progressDrawable", "indeterminateDrawable"}).ˊ();
        ˋ.put(ˊ.ˎ(), ˊ);
        ˊ = new a().ˏ("textAppearance").ˎ("android.widget.TextView").ˊ("com.android.internal.R$styleable").ˋ("TextAppearance").ˎ(new String[]{"TextAppearance_textColor", "TextAppearance_textColorHint"}).ॱ(new String[]{"textColor", "textColorHint"}).ˊ();
        ˊ.put(ˊ.ˎ(), ˊ);
        ˊ = new a().ˏ("textAppearance").ˎ("androidx.appcompat.widget.AppCompatTextView").ˊ("com.android.internal.R$styleable").ˋ("TextAppearance").ˎ(new String[]{"TextAppearance_textColor", "TextAppearance_textColorHint"}).ॱ(new String[]{"textColor", "textColorHint"}).ˊ();
        ˊ.put(ˊ.ˎ(), ˊ);
        ˊ = new a().ˏ("textAppearance").ˎ("android.widget.Button").ˊ("com.android.internal.R$styleable").ˋ("TextAppearance").ˎ(new String[]{"TextAppearance_textColor", "TextAppearance_textColorHint"}).ॱ(new String[]{"textColor", "textColorHint"}).ˊ();
        ˊ.put(ˊ.ˎ(), ˊ);
        ˊ = new a().ˏ("textAppearance").ˎ("android.widget.EditText").ˊ("com.android.internal.R$styleable").ˋ("TextAppearance").ˎ(new String[]{"TextAppearance_textColor", "TextAppearance_textColorHint"}).ॱ(new String[]{"textColor", "textColorHint"}).ˊ();
        ˊ.put(ˊ.ˎ(), ˊ);
        ˊ = new a().ˏ("textAppearance").ˎ("com.huawei.support.widget.HwTextView").ˊ("com.android.internal.R$styleable").ˋ("TextAppearance").ˎ(new String[]{"TextAppearance_textColor", "TextAppearance_textColorHint"}).ॱ(new String[]{"textColor", "textColorHint"}).ˊ();
        ˊ.put(ˊ.ˎ(), ˊ);
        ˊ = new a().ˏ("textAppearance").ˎ("com.huawei.support.widget.HwButton").ˊ("com.android.internal.R$styleable").ˋ("TextAppearance").ˎ(new String[]{"TextAppearance_textColor", "TextAppearance_textColorHint"}).ॱ(new String[]{"textColor", "textColorHint"}).ˊ();
        ˊ.put(ˊ.ˎ(), ˊ);
    }

    public fpf(View view, @NonNull String str) {
        this.ˏ = view;
        this.ॱॱ = str;
        ˏ();
    }

    public void ॱ(Context context, Resources resources, int i, List<SkinAttr> list) {
        if (this.ॱ == null) {
            fmq.ˊ("prepare failed(mStyleBean is null): have register style for this view? : " + this.ˏ.getClass().getSimpleName());
            return;
        }
        int[][] ॱ = ॱ(this.ॱ.ˏ(), this.ॱ.ˋ(), this.ॱ.ˊ());
        if (ॱ == null || ॱ.length != 2 || ॱ[0] == null) {
            fmq.ˊ("parseStyle failed!");
            return;
        }
        list.clear();
        ˋ(context.getTheme().obtainStyledAttributes(i, ॱ[0]), resources, ॱ[1], this.ॱ.ᐝ(), list);
    }

    private void ˏ() {
        fku o_fku;
        if (this.ॱॱ.equals("style")) {
            o_fku = (fku) ˋ.get(this.ˏ.getClass().getName());
            if (o_fku != null) {
                this.ॱ = o_fku;
            }
        } else if (this.ॱॱ.equals("textAppearance")) {
            o_fku = (fku) ˊ.get(this.ˏ.getClass().getName());
            if (o_fku != null) {
                this.ॱ = o_fku;
            }
        }
    }

    private void ˋ(TypedArray typedArray, Resources resources, int[] iArr, String[] strArr, List<SkinAttr> list) {
        for (int i = 0; i < iArr.length; i++) {
            if (-1 != iArr[i]) {
                int resourceId;
                try {
                    resourceId = typedArray.getResourceId(iArr[i], -1);
                } catch (Exception e) {
                    fmq.ˎ("StyleHelper.parse() getResourcesId failed! (AttrName: " + strArr[i] + ")");
                    resourceId = -1;
                }
                if (resourceId != -1) {
                    SkinAttr o_fko = SkinAttrFactory.get(strArr[i], resourceId, resources.getResourceEntryName(resourceId), resources.getResourceTypeName(resourceId), this.ˏ.getClass());
                    if (o_fko != null) {
                        list.add(o_fko);
                    }
                }
            }
        }
    }

    private int[][] ॱ(String str, String str2, String[] strArr) {
        Object ॱ = ॱ(str, str2);
        int[] iArr = null;
        if (ॱ != null && (ॱ instanceof int[])) {
            iArr = (int[]) ॱ;
        }
        int[] iArr2 = new int[strArr.length];
        for (int i = 0; i < strArr.length; i++) {
            ॱ = ॱ(str, strArr[i]);
            if (ॱ == null || !(ॱ instanceof Integer)) {
                iArr2[i] = -1;
            } else {
                iArr2[i] = ((Integer) ॱ).intValue();
            }
        }
        return new int[][]{iArr, iArr2};
    }

    private Object ॱ(String str, String str2) {
        Map map = (Map) ˎ.get(str);
        Field field;
        if (map != null) {
            field = (Field) map.get(str2);
            if (field != null) {
                return fmt.ॱ(field, null);
            }
            try {
                field = fmt.ˊ(Class.forName(str), str2);
                map.put(str2, field);
                return fmt.ॱ(field, null);
            } catch (ClassNotFoundException e) {
                fmq.ˎ("StyleHelper.getFieldValue Error1 " + e.getMessage());
                return null;
            }
        }
        map = new HashMap();
        ˎ.put(str, map);
        try {
            field = fmt.ˊ(Class.forName(str), str2);
            map.put(str2, field);
            return fmt.ॱ(field, null);
        } catch (ClassNotFoundException e2) {
            fmq.ˎ("StyleHelper.getFieldValue Error1 " + e2.getMessage());
            return null;
        }
    }

    public static void ˎ(List<fku> list) {
        for (fku o_fku : list) {
            if (!o_fku.ॱॱ()) {
                fmq.ˊ("StyleHelper.expandStyle Error: StyleBean: " + o_fku.toString());
            } else if ("style".equals(o_fku.ॱ())) {
                ˋ.put(o_fku.ˎ(), o_fku);
            } else if ("textAppearance".equals(o_fku.ॱ())) {
                ˊ.put(o_fku.ˎ(), o_fku);
            }
        }
    }
}
